#include <stdio.h>


int fgets_l (char *str, int sz, FILE *fp)
{
	char aa;
	char old_aa;
	int i;

	for ( i = 0; i < sz; i++ ){
		aa = fgetc(fp);
/*
		printf("%c", (char)aa);
*/
		*(str + i) = aa;
		if( (old_aa == '\n') && (aa == '\r') )
			 break;
		old_aa = aa;
	}
/*
	printf("\n");
*/
	*(str + i) = 0;
	return(i - 1);
}
#if 0
main()
{
	FILE *fp;

	char aa[4000];
	int	s_len;

	if(( fp = fopen("./4.log", "rb")) == NULL) {
		fprintf(stderr, "File open error\n");
	}

	s_len = fgets_l(aa, 4000, fp);
	printf(">[%d]%s<\n", s_len, aa);
	HexLog( aa, s_len);

/*
	s_len = fgets_l(aa, 4000, fp);
	printf("[%d]>%s<\n", s_len, aa);
*/
}
#endif


